package com.yangle.frame.admin.mapper;


import com.yangle.frame.MyMapper;
import com.yangle.frame.admin.entity.FrameDatabase;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FrameDatabaseMapper extends MyMapper<FrameDatabase> {
/**
 * 批量删除
 */
@Delete("<script> delete from frame_database where id in "
        + "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>"
        + "#{item}"
        + "</foreach> </script>")
public void deletes(@Param("ids") List<String> ids);
    /**
     * 创建表
     */
    @Update("create table ${tableName}(id varchar(255) PRIMARY KEY)")
    void createTable(@Param("tableName") String tableName);
    /**
     * 更新表名
     */
    @Update("ALTER  TABLE ${preName} RENAME TO ${tableName}")
    void alterTableName(@Param("preName") String preName,@Param("tableName") String tableName);
    /**
     * 删除表
     */
    @Update("drop table if exists ${tableName}")
    void dropTable(@Param("tableName") String tableName);
    /**
     * 查询表是否存在
     */
    @Select("select count(1) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA=#{databasename} and TABLE_NAME=#{tableName}")
    @ResultType(value=int.class)
    int queryTableIsExists(@Param("databasename") String databasename,@Param("tableName") String tableName);
}
